package mfuny.ggongal.admin;

import mfuny.ggongal.admin.notice.NoticeDao;
import mfuny.ggongal.admin.notice.NoticeService;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class NoticeController {
	NoticeService ns;
	
	public NoticeController() throws Exception {
		ns = new NoticeService();
	}
	
	@RequestMapping("/noticeList.ga")
	public ModelAndView noticeList() throws Exception {
		return ns.noticeList( );
	}
	
	@RequestMapping("/regNoticeForm.ga")
	public ModelAndView regNoticeForm() throws Exception {
		return ns.regNoticeForm( );
	}
	
	@RequestMapping("/regNotice.ga")
	public ModelAndView regNotice( @ModelAttribute NoticeDao noticeClass ) throws Exception {
		ns.regNotice( noticeClass );
		return noticeList();
	}
	
	@RequestMapping("/readNotice.ga")
	public ModelAndView readNotice( int notice_no ) throws Exception {
		return ns.readNotice( notice_no );
	}
	
	@RequestMapping("/deleteNoticePopup.ga")
	public ModelAndView deleteNoticePopup( int notice_no ) throws Exception {
		return ns.deleteNoticePopup( notice_no );
	}
	
	@RequestMapping("/deleteNotice.ga")
	public void deleteNotice( int notice_no ) throws Exception {
		ns.deleteNotice( notice_no );
	}
	
	@RequestMapping("/modifyNoticeForm.ga")
	public ModelAndView modifyNoticeForm( int notice_no ) throws Exception {
		return ns.modifyNoticeForm( notice_no );
	}
	
	@RequestMapping("/modifyNotice.ga")
	public ModelAndView modifyNotice(@ModelAttribute NoticeDao noticeClass ) throws Exception {
		ns.modifyNotice( noticeClass );
		return noticeList();
	}
}
